package com.tuanda.app.customviewdemo.cavans;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by LiDongduo on 2018/9/19.
 */
public class DrawLineView extends View {

    private Paint mPaint;

    public DrawLineView(Context context) {
        this(context,null);
    }

    public DrawLineView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,0);
    }

    public DrawLineView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mPaint.setColor(Color.RED);
        mPaint.setStrokeWidth(20);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawLine(50,50,120,70,mPaint);

        float[] pts = new float[]{0,10,0,100,
                50,100,150,100,
                50,160,150,160};
        canvas.drawLines(pts,4,8,mPaint);
    }
}
